package chapter15.exercise;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomList<T> {
    private List<T> list = new ArrayList<>();
    private Random rand = new Random(47);

    public void add(T item) {
        list.add(item);
    }

    public T select() {
        return list.get(rand.nextInt(list.size()));
    }

    public static void main(String[] args) {
        RandomList<String> list = new RandomList<>();
        for (String s : "The quick brown fox jumped over the lazy brown dog".split(" ")) {
            list.add(s);
        }
        for (int i = 0; i < 11; i++) {
            System.out.print(list.select() + " ");
        }
    }
}
